﻿using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Extensions.DependencyInjection;
namespace Marmat.FrameWork
{
    public static class AutoUpgradeExtension
    {
        /// <summary>
        /// 启用自动更新程序。
        /// </summary>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static void EnabledAutoUpgrade(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string host)
        {
            Marmat.Template.Upgrade.UpgradeClient upgrade = new Marmat.Template.Upgrade.UpgradeClient();
            upgrade.Host = host;
            upgrade.StartupApplication = new FileInfo(Application.ExecutablePath).Name;
            services.AddSingleton<Marmat.Foundation.IUpgrade>((o) => upgrade);
        }
    }
}
